import java.util.Arrays;
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        int[] arr = {3,2,5,6,0,9,7,8,1,4};
        QuickSort(arr,0,arr.length-1);
        System.out.println(Arrays.toString(arr));
    }
    public static void QuickSort(int[] arr,int left, int right){
        if(left >= right){
            return;
        }
        int i = left;
        int j = right;
        //基准
        int base = arr[left];
        while(i < j){
            while(i < j && arr[j] >= base){
                j--;
            }
            while(i < j && arr[i] <= base){
                i++;
            }
            //交换
            if(i < j){
                int tmp = arr[i];
                arr[i] = arr[j];
                arr[j] = tmp;
            }
        }
        arr[left] = arr[i];
        arr[i] = base;
        //左边
        QuickSort(arr, left, i-1);
        //右边
        QuickSort(arr, i+1, right);
       
    }
}